from pydantic import BaseModel
from typing import Optional
import datetime

# Shared properties
class UserBase(BaseModel):
    email: str  # 暂时使用 str 而不是 EmailStr
    username: str

# Properties to receive via API on creation
class UserCreate(UserBase):
    password: str

# Properties to receive via API on update
class UserUpdate(BaseModel):
    email: Optional[str] = None  # 暂时使用 str 而不是 EmailStr
    username: Optional[str] = None
    password: Optional[str] = None
    avatar_url: Optional[str] = None

class UserInDBBase(UserBase):
    id: int
    avatar_url: Optional[str] = None
    credits_balance: int
    created_at: datetime.datetime

    class Config:
        from_attributes = True

# Additional properties to return via API
class User(UserInDBBase):
    pass

# Additional properties stored in DB
class UserInDB(UserInDBBase):
    hashed_password: str
